<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: head('通知编辑')"></head>
<body>
<div class="yadmin-body animated fadeIn">
    <div class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label for="title" class="layui-form-label"><span class="yadmin-red">*</span>标题</label>
            <div class="layui-input-block">
                <input type="text" id="title" placeholder="请输入账号名" name="title" th:value="${noticeId}" lay-verify="required" lay-vertype="tips" autocomplete="off" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label for="content" class="layui-form-label"><span class="yadmin-red">*</span>内容</label>
            <div class="layui-input-block">
                <input type="text" id="content" placeholder="请输入备注" name="content" th:value="${content}" lay-verify="required" lay-vertype="tips" autocomplete="off" class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="margin-left:0;text-align:center;">
                <button class="layui-btn layui-btn-normal btn-w100" lay-submit="" lay-filter="submit-form">保存</button>
            </div>
        </div>
    </div>
</div>
<script>
layui.use(['form', 'layer'], function () {
    var form = layui.form, layer = layui.layer, $ = layui.$;
    
    form.on('submit(submit-form)', function (obj) {
        $.ajax({
            type: "POST",
            url: '/notice/save',
            data: obj.field,
            dataType: 'json',
            cache: false,
            success: function (data) {
                let index = parent.layer.getFrameIndex(window.name);
                parent.location.replace(parent.location.href)
                parent.layer.close(index);
            },
            error: function (event) {
                errors(event);
            }
        });
    });
});
</script>
</body>
</html>
